define(['template', 'jquery'], (template) => {
    class Header {
        constructor() {
            this.loadHTML().then(() => {
                this.kefu()
                this.getData()
            })
        }
        loadHTML() {
            return new Promise((resolve, reject) => {
                $('header').load('/html/modules/header.html', () => {
                    resolve()
                })
            })
        }
        kefu() {
            $(".kefu").on('click', function() {
                alert("111")
            })
        }
        getData() {
            // 从熊猫优选渲染nav
            $.ajax({
                type: "get",
                url: "/api/column/29",
                dataType: "json",
                success: function(resp) {
                    resp.data.subColumns.pop()
                    let html = template("header-nav-template", {
                        list: resp.data.subColumns
                    })
                    $(".header-ul").html(html)

                    let html2 = template("down-content-template", {
                        data: resp.data.subColumns
                    })
                    $(".list-box-contain").html(html2)

                    let html3 = template("content-li-template", {
                        data: resp.data.subColumns
                    })
                    $(".itme-list").html(html3)



                }
            })
        }
    }
    return new Header();
});